<?php
/**
 * ShopEx licence
 *
 * @copyright  Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn)
 * @license  http://ecos.shopex.cn/ ShopEx License
 */

class desktop_ctl_lang extends desktop_controller{

    function index(){
        $custom_actions[] =  array('label'=>app::get('b2c')->_('翻译'),'submit'=>'index.php?app=desktop&ctl=lang&act=fanyi','target'=>'dialog::{title:\''.app::get('b2c')->_('翻译').'\',width:700,height:400}');
        $this->finder('desktop_mdl_lang',array(
            'title'=>app::get('desktop')->_('俄语翻译'),
            'actions'=>$custom_actions,
			'use_buildin_filter'=>true,
            ));
    }
    function fanyi(){
        if($_POST['isSelectedAll'] == '_ALL_'){
            $aMember = array();
            $view_filter = $this->get_view_filter('desktop_ctl_lang','desktop_mdl_lang');
            $obj_member = app::get('desktop')->model('lang',$view_filter);
            $aData = $obj_member->getList('id');
            foreach((array)$aData as $key => $val){
                $aMember[] = $val['id'];
            }
        }
        else{
            $aMember = $_POST['id'];
        }
        $data=app::get('desktop')->model('lang')->getlist('id,`key`,lkey',array('id'=>$aMember));
        $this->pagedata['fanyi'] = $data;
        $this->page('lang/fanyi.html');
    }
    function save_fanyi(){
        $data=$_POST['fanyi'];
        $this->begin();
        if($data){
            foreach($data as $key=>$v){
                app::get('desktop')->model('lang')->save($v);
            }
        }
        $this->end(true,app::get('desktop')->_('操作成功！'));
    }
}
